using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableCopyMissionDao:DaoBase<TableCopyMission>
    {
        public override void AddPrimaryIndex(TableCopyMission model)
        {
            cachePrimary[model.MissionId.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableCopyMission.txt";
        }

        protected override TableCopyMission ParseRowData(string[] rowData)
        {
            TableCopyMission data = new TableCopyMission();
			data.MissionId = rowData [0];
			data.ChapterId = rowData [1];
			data.SceneName = rowData [2];
			data.MissionName = rowData [3];
			data.OpenId = rowData [4];
			data.SmallIcon = rowData [5];
			data.BigIcon = rowData [6];

            if (string.IsNullOrEmpty(rowData[7]))
            {
                data.CameraAngle = 0;
            }
            else
            {
                data.CameraAngle = double.Parse(rowData[7]);
            }

            if (string.IsNullOrEmpty(rowData[8]))
            {
                data.BornX = 0;
            }
            else
            {
                data.BornX = double.Parse(rowData[8]);
            }

            if (string.IsNullOrEmpty(rowData[9]))
            {
                data.BornZ = 0;
            }
            else
            {
                data.BornZ = double.Parse(rowData[9]);
            }

            if (string.IsNullOrEmpty(rowData[10]))
            {
                data.FaceTo = 0;
            }
            else
            {
                data.FaceTo = int.Parse(rowData[10]);
            }
			data.DropShow = rowData [11];

            if (string.IsNullOrEmpty(rowData[12]))
            {
                data.PowerCost = 0;
            }
            else
            {
                data.PowerCost = int.Parse(rowData[12]);
            }

            if (string.IsNullOrEmpty(rowData[13]))
            {
                data.ChallengeCount = 0;
            }
            else
            {
                data.ChallengeCount = int.Parse(rowData[13]);
            }

            return data;
        }


        public override void AddOneIndex(TableCopyMission model)
        {
            if (!cacheOneIndex.ContainsKey(model.ChapterId.ToString()))
            {
                cacheOneIndex[model.ChapterId.ToString()] = new List<TableCopyMission>();
            }
            cacheOneIndex[model.ChapterId.ToString()].Add(model);
        }
    

    }

}
